package east;

import java.util.Random;

import robocode.AdvancedRobot;
import robocode.DeathEvent;
import robocode.HitByBulletEvent;
import robocode.HitWallEvent;
import robocode.RobotDeathEvent;
import robocode.ScannedRobotEvent;
import robocode.WinEvent;

// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html

/**
 * Test - a robot by (your name here)
 */
public class Test extends AdvancedRobot
{
	public Scanner scanner;
	public CircleMover circlemover;
	private Tracker tracker;
	public Random generator = new Random();
	
	private double maxspeed = 1000;
	private double speed = maxspeed;
		
	
	/**
	 * run: Test's default behavior
	 */
	public void run() {

		scanner = new Scanner(this);
		circlemover = new CircleMover(this);
		tracker = new Tracker(this);
		
		do
		{
			scanner.move();
			circlemover.move(speed);
			tracker.move();
		}
		while (true);
	}
	
	public void onRobotDeath(RobotDeathEvent e)
	{
		scanner.onRobotDeath(e);
	}

	/**
	 * onScannedRobot: What to do when you see another robot
	 */
	public void onScannedRobot(ScannedRobotEvent e)
	{
		scanner.onScan(e);	
	}

	/**
	 * onHitByBullet: What to do when you're hit by a bullet
	 */
	public void onHitByBullet(HitByBulletEvent e) 
	{	
		//new AePlayWave(this.getDataFile("ow.wav")).start();
		speed = (1 - 2 * generator.nextDouble()) * maxspeed;
	}
	
	/**
	 * onHitWall: What to do when you hit a wall
	 */
	public void onHitWall(HitWallEvent e) 
	{
		speed = -speed;
	}
	
	public void onDeath(DeathEvent e)
	{
		scanner.onDeath(e);
	}
	
	public void onWin(WinEvent e)
	{
		scanner.onWin(e);
	}
	
	
}
